package org.redr.canvas;

import org.redr.widgetGUI.core.TextEdit;

public class RedRLog {
	static TextEdit	output = null;
	public static final int REDRCORE = 0;
	public static final int CRITICAL = 10;
	public static final int ERROR = 5;
	public static String[] callers = {"Core", "R", "Widget", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown"};
	public static int core = 0;
	public static int r = 1;
	public static int widget = 2;
	public static int unknown = 10;
	
	
	public static String[] calltos = {"Warning", "", "", "Info", "", "Debug", "", "", "", "", "Unknown"};
	public static int info = 3;
	public static int warning = 0;
	public static int devel = 5;
	public static int debug = 10;
	
	public static void connectTextEdit(TextEdit out){
		output = out;
	}
	
	public static void log(String s)
	{
		log(unknown, debug, s);
	}
	
	public static void log(int caller, int callto, String s)
	{
		
		int callerf = caller <= 10 ? caller : 10;
		int calltof = callto <= 10 ? callto : 10;
		
		if (output == null){
			System.out.println("Call from " + callers[callerf]);
			System.out.println("Call level " + calltos[calltof]);
			System.out.println(s + "\n");
		} else {
			output.append(String.format("%s,  %s: %s", callers[callerf], callers[calltof], s));
		}
		
		
	}

	public static String formatException(Exception e) {
		// TODO Auto-generated method stub
		return null;
	}
}
